package com.java.yz.day08.homework;
/*
    1.  编写程序实现比萨制作。需求说明编写程序，接收用户输入的信息，
    选择需要制作的比萨。可供选择的比萨有：培根比萨和海鲜比萨。
    实现思路及关键代码
    1)     分析培根比萨和海鲜比萨
    2)     定义比萨类
    3)     属性：名称、价格、大小
    4)     方法：展示
    5)     定义培根比萨和海鲜比萨继承自比萨类
    6)     定义测试类，根据输入信息产生具体的比萨对象
 */
import java.util.Scanner;
abstract class PiSa{
    String name;
    double price;
    double size;
    double g;
    public double getG() {
        return g;
    }

    public void setG(double g) {
        this.g = g;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    public double getSize() {
        return size;
    }
    public void setSize(double size) {
        this.size = size;
    }
    public abstract void show();
}
class Bacon extends PiSa{
    @Override
    public void show() {
        System.out.println("名称：培根披萨");
        System.out.println("价格："+getPrice()+"元");
        System.out.println("大小："+getSize()+"寸");
        System.out.println("培根克数："+getG()+"克");
    }
}
class SeaFood extends PiSa{
    public String getDosing() {
        return dosing;
    }

    public void setDosing(String dosing) {
        this.dosing = dosing;
    }

    String dosing;
    @Override
    public void show() {
        System.out.println("名称：海鲜披萨");
        System.out.println("价格："+getPrice()+"元");
        System.out.println("大小："+getSize()+"寸");
        System.out.println("配料："+getDosing());

    }
}
public class Text01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你想制作的披萨（1.培根披萨 2.海鲜披萨）：");
        int i = scanner.nextInt();
        if (i==1){
            Bacon bacon = new Bacon();
            System.out.println("请输入培根克数：");
            double g = scanner.nextDouble();
            bacon.setG(g);
            System.out.println("请输入披萨大小：");
            double size = scanner.nextDouble();
            bacon.setSize(size);
            System.out.println("请输入披萨价格：");
            double price = scanner.nextDouble();
            bacon.setPrice(price);
            bacon.show();
        }
        else {
            SeaFood seaFood = new SeaFood();
            System.out.println("请输入配料信息：");
            String dosing = scanner.next();
            seaFood.setDosing(dosing);
            System.out.println("请输入披萨大小：");
            double size = scanner.nextDouble();
            seaFood.setSize(size);
            System.out.println("请输入披萨价格：");
            double price = scanner.nextDouble();
            seaFood.setPrice(price);
            seaFood.show();
        }
    }
}
